package com.xqls.dal.dao.mybatis;

import com.xqls.dal.dao.SamplingRecordDao;
import com.xqls.dal.model.SamplingRecord;
import com.xqls.dal.model.SamplingRecordExample;
import com.xqls.dal.service.SamplingRecordMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

@Repository
public class SamplingRecordDaoImpl implements SamplingRecordDao{

	
	@Autowired private SamplingRecordMapper mapper;
	@Override
	public int insertSamplingRecordList(SamplingRecord samplingRecord) {
		
		return mapper.insertSelective(samplingRecord);
	}

	@Override
	public SamplingRecord queryByExample(SamplingRecordExample example) {
	  List<SamplingRecord> list=	mapper.selectByExample(example);
		if(list!=null&&list.size()>0) return  list.get(0);
		return null;
	}

	public int updateSamplingRecordList(SamplingRecord samplingRecord){
		return mapper.updateByPrimaryKeySelective(samplingRecord);
	}
	
	public SamplingRecord queryByRecordNo(Integer recordNo){
		return mapper.selectByPrimaryKey(recordNo);
	}
	@Override
	public List<Map<String, Object>> selectByMap(Map<String, Object> map,String sampleType) {
		map.put("sampleType", sampleType);
		return mapper.selectByMap(map);
	}
	
	
	public SamplingRecord queryDischargeByDeviceNo(String deviceNo){
		return mapper.selectDischargeBydeviceNo(deviceNo);
	}
	
	public SamplingRecord queryRecordByDeviceNo(String deviceNo,String sampleType){
		return mapper.selectRrcordNoBydeviceNo(deviceNo, sampleType);
	}

	@Override
	public List<Map<String, Object>> getListByMap(Map<String, Object> map) {
		return this.mapper.getListByMap(map);
	}

}
